<?php

namespace Core\Forms\Element;

class Selects extends Select
{
    public function getValue()
    {
        $value = parent::getValue();
        $output = [];
        if (is_array($value)) {
            foreach ($value as $name) {
                $output[$name] = $name;
            }
            return $output;
        }
        return $value;
    }

    public function render($attributes = null)
    {
        $attributes = $this->prepareAttributes($attributes);
        $attributes['name'] = $this->_name . '[]';
        $attributes = array_merge(array(
            'multiple' => 'multiple',
        ), $attributes);
        return parent::render($attributes);
    }
}
